package com.wnxy.test;

import com.wnxy.pojo.Person;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.time.Duration;
import java.util.Set;
import java.util.concurrent.TimeUnit;

@SpringBootTest
public class App2 {
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @Test
    public void test1(){
        redisTemplate.opsForValue().set("name","小张", Duration.ofMinutes(1));
        redisTemplate.opsForValue().set("person",new Person(101,"小猿"));

        System.out.println(redisTemplate.opsForValue().get("name"));
        System.out.println(redisTemplate.opsForValue().get("person"));
    }

    @Test
    public void test2(){
        System.out.println("key序列化方式："+redisTemplate.getKeySerializer());
        System.out.println("value序列化方式："+redisTemplate.getValueSerializer());
    }
}
